package models

import (
	"log"

	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var DB *gorm.DB

func InitDB() {
	// dsn := "root:@tcp(127.0.0.1:3306)/tiku?charset=utf8mb4"
	dsn := "root:@tcp(127.0.0.1:3306)/tiku?charset=utf8mb4&parseTime=True&loc=Local"

	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		log.Fatalln(err)
	}
	DB = db
	DB.AutoMigrate(&User{})
}
